<?php declare(strict_types=1);
/**
 * @author      guosir
 * @copyright   2023-2025 owner
 **/

namespace Srv\Apps\Apis\Common\Ctl;

use Srv\Apps\Apis\Common\DefCtl\DefDeviceBrandCtl;
use Srv\Apps\Apis\Common\DefCtl\DefDeviceCodeCtl;
use Srv\Apps\Apis\Common\DefCtl\DefDeviceLangCtl;
use Srv\Apps\Apis\Common\DefCtl\DefDeviceModelCtl;
use Srv\Apps\Apis\Common\DefCtl\DefDeviceNetCtl;
use Srv\Apps\Apis\Common\DefCtl\DefDeviceOsCtl;
use Srv\Apps\Apis\Common\DefCtl\DefPlatformCtl;
use Srv\Apps\Proto\Enum\Common\DeviceTypeEnum;
use Srv\Apps\Proto\Enum\YesOrNoEnum;
use Srv\Apps\Proto\VO\Common\AndroidInfoVO;
use Srv\Apps\Proto\VO\Common\AppleInfoVO;
use Srv\Apps\Proto\VO\Common\DevicePushUserVO;
use Srv\Apps\Proto\VO\Common\OtherInfoVO;
use Srv\Libs\Common\CommArray;
use Srv\Libs\Frame\ControllerAbstract;
use Srv\Libs\Storage\DataMysql;

final class DevicePushCtl extends ControllerAbstract
{
    private ?DataMysql $DbAuto                  = null;     // DB-Write

    /**
     * @return static
     * tag
     */
    final public static function tag():self
    {
        $thisObject                         = self::tagGet();
        if($thisObject instanceof self){
            $thisObject->DbAuto             = self::getDbAuto();
        }
        return $thisObject;
    }

    /**
     * @param int $dupId
     * @return array
     * getDevicePushUserSrc
     */
    public function getDevicePushUserSrc(int $dupId):array
    {
        if($dupId < 1) return [];
        $isFail     = false;
        $info       = $this->DbAuto->getDataOne('SELECT dup_id, dup_uuid, dup_type, dani_id, dapi_id, dopi_id, dup_push, dup_push_id, dup_push_regid, dup_push_token, user_id_first, user_id_last, dup_create_time, dup_update_time FROM '.$this->DbAuto->getTableNameAll('device_push_user').' WHERE dup_id='.$dupId, $isFail);
        if($isFail || !isset($info['dup_id'])) return [];
        return $info;
    }

    /**
     * @param array $dupIdList
     * @return array
     * getDevicePushUserSrcBatch
     */
    public function getDevicePushUserSrcBatch(array $dupIdList):array
    {
        if(count($dupIdList) < 1) return [];
        $isFail     = false;
        $list       = $this->DbAuto->getData('SELECT dup_id, dup_uuid, dup_type, dani_id, dapi_id, dopi_id, dup_push, dup_push_id, dup_push_regid, dup_push_token, user_id_first, user_id_last, dup_create_time, dup_update_time FROM '.$this->DbAuto->getTableNameAll('device_push_user').' WHERE dup_id IN('.implode(',', $dupIdList).')', $isFail);
        $listData   = [];
        if(!$isFail && CommArray::isForeach($list)) foreach ($list as $item){
            $dupIdItem              = intval($item['dup_id']??0);
            if($dupIdItem < 1) continue;
            $listData[$dupIdItem]   = $item;
        }
        return $listData;
    }

    /**
     * @param array $dupIdList
     * @return array
     * getDevicePushUserBatch
     */
    public function getDevicePushUserBatch(array $dupIdList):array
    {
        $list       = $this->getDevicePushUserSrcBatch($dupIdList);
        $listData   = [];
        if(CommArray::isForeach($list)){
            $daniIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'dani_id'))));
            $AndroidInfoVOList  = $this->getAndroidInfoBatch($daniIdList);
            $dapiIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'dapi_id'))));
            $AppleInfoVOList    = $this->getAppleInfoBatch($dapiIdList);
            $dopiIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'dopi_id'))));
            $OtherInfoVOList    = $this->getOtherInfoBatch($dopiIdList);
            foreach ($list as $dupId => $item){
                $DevicePushUserVO   = $this->getDevicePushUserVO($item);
                if(!($DevicePushUserVO instanceof DevicePushUserVO)) continue;
                $AndroidInfoVO      = $AndroidInfoVOList[intval($item['dani_id'])]??null;
                $AppleInfoVO        = $AppleInfoVOList[intval($item['dapi_id'])]??null;
                $OtherInfoVO        = $OtherInfoVOList[intval($item['dopi_id'])]??null;
                if($AndroidInfoVO instanceof AndroidInfoVO) $DevicePushUserVO->setAndroidInfo($AndroidInfoVO);
                if($AppleInfoVO instanceof AppleInfoVO) $DevicePushUserVO->setAppleInfo($AppleInfoVO);
                if($OtherInfoVO instanceof OtherInfoVO) $DevicePushUserVO->setOtherInfo($OtherInfoVO);
                $listData[$dupId]   = $DevicePushUserVO;
            }
        }
        return $listData;
    }

    /**
     * @param int $dupId
     * @return DevicePushUserVO|null
     * getDevicePushUser
     */
    public function getDevicePushUser(int $dupId):?DevicePushUserVO
    {
        $info   = $this->getDevicePushUserSrc($dupId);
        if(!isset($info['dup_id'])) return null;
        return $this->getDevicePushUserVO($info);
    }

    /**
     * @param array $info
     * @return DevicePushUserVO|null
     * getDevicePushUserVO
     */
    public function getDevicePushUserVO(array $info):?DevicePushUserVO
    {
        $dupId              = intval($info['dup_id']??0);
        if($dupId < 1) return null;
        $DevicePushUserVO   = new DevicePushUserVO();
        $DevicePushUserVO->setDupId($dupId);
        $DevicePushUserVO->setUuid($info['dup_uuid']);
        $DevicePushUserVO->setType(DeviceTypeEnum::parseValue($info['dup_type']));
        $DevicePushUserVO->setPush(YesOrNoEnum::parseValue($info['dup_push']));
        $DevicePushUserVO->setUserIdFirst(intval($info['user_id_first']));
        $DevicePushUserVO->setUserIdLast(intval($info['user_id_last']));
        return $DevicePushUserVO;
    }

    /**
     * @param array $daniIdList
     * @return array
     * getAndroidInfoSrcBatch
     */
    public function getAndroidInfoSrcBatch(array $daniIdList):array
    {
        if(count($daniIdList) < 1) return [];
        $isFail     = false;
        $sql        = 'SELECT dani_id, imei_id, imei_id_two, sn_id, oaid_id, ua_id, ddnt_id, ddpt_id, ddlt_id, ddot_id, ddmt_id, ddbt_id, ddct_id, dani_width, dani_height FROM '.$this->DbAuto->getTableNameAll('device_android_info').' WHERE dani_id IN('.implode(',', $daniIdList).')';
        $list       = $this->DbAuto->getData($sql, $isFail);
        $listData   = [];
        if(!$isFail && CommArray::isForeach($list)){
            foreach ($list as $item){
                $daniIdItem             = intval($item['dani_id']??0);
                if($daniIdItem < 1) continue;
                $listData[$daniIdItem]  = $item;
            }
        }
        return $listData;
    }

    /**
     * @param array $daniIdList
     * @return array
     * getAndroidInfoBatch
     */
    public function getAndroidInfoBatch(array $daniIdList):array
    {
        $list       = $this->getAndroidInfoSrcBatch($daniIdList);
        $listData   = [];
        if(CommArray::isForeach($list)){
            $DefDeviceNetCtl    = DefDeviceNetCtl::tag();
            $DefPlatformCtl     = DefPlatformCtl::tag();
            $DefDeviceLangCtl   = DefDeviceLangCtl::tag();
            $DefDeviceOsCtl     = DefDeviceOsCtl::tag();
            $DefDeviceModelCtl  = DefDeviceModelCtl::tag();
            $DefDeviceBrandCtl  = DefDeviceBrandCtl::tag();
            $DefDeviceCodeCtl   = DefDeviceCodeCtl::tag();
            // imei
            $imeiIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'imei_id'))));
            $imeiIdTwoList      = array_unique(array_map('intval', array_filter(array_column($list, 'imei_id_two'))));
            $imeiList           = $this->getImeiByIdBatch(array_merge_recursive($imeiIdList, $imeiIdTwoList));
            // sn
            $snIdList           = array_unique(array_map('intval', array_filter(array_column($list, 'sn_id'))));
            $snList             = $this->getSnByIdBatch($snIdList);
            // oaid
            $oaidIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'oaid_id'))));
            $oaidList           = $this->getOaidByIdBatch($oaidIdList);
            // ua
            $uaIdList           = array_unique(array_map('intval', array_filter(array_column($list, 'ua_id'))));
            $uaList             = $this->getUaByIdBatch($uaIdList);
            // devNet
            $ddntIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'ddnt_id'))));
            $devNetList         = $DefDeviceNetCtl->getExtStrByIdBatch($ddntIdList, DefDeviceNetCtl::EXT_NAME);
            // devPlatform
            $ddptIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'ddpt_id'))));
            $devPlatformList    = $DefPlatformCtl->getExtStrByIdBatch($ddptIdList, DefPlatformCtl::EXT_NAME);
            // devLang
            $ddltIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'ddlt_id'))));
            $devLangList        = $DefDeviceLangCtl->getExtStrByIdBatch($ddltIdList, DefDeviceLangCtl::EXT_NAME);
            // devOs
            $ddotIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'ddot_id'))));
            $devOsList          = $DefDeviceOsCtl->getExtStrByIdBatch($ddotIdList, DefDeviceOsCtl::EXT_NAME);
            // devModel
            $ddmtIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'ddmt_id'))));
            $devModelList       = $DefDeviceModelCtl->getExtStrByIdBatch($ddmtIdList, DefDeviceModelCtl::EXT_NAME);
            // devBrand
            $ddbtIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'ddbt_id'))));
            $devBrandList       = $DefDeviceBrandCtl->getExtStrByIdBatch($ddbtIdList, DefDeviceBrandCtl::EXT_NAME);
            // devCode
            $ddctIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'ddct_id'))));
            $devCodeList        = $DefDeviceCodeCtl->getExtStrByIdBatch($ddctIdList, DefDeviceCodeCtl::EXT_NAME);
            foreach ($list as $daniId => $item){
                $AndroidInfoVO      = new AndroidInfoVO();
                $ddntIdItem         = intval($item['ddnt_id']);
                $ddptIdItem         = intval($item['ddpt_id']);
                $ddltIdItem         = intval($item['ddlt_id']);
                $ddotIdItem         = intval($item['ddot_id']);
                $ddmtIdItem         = intval($item['ddmt_id']);
                $ddbtIdItem         = intval($item['ddbt_id']);
                $ddctIdItem         = intval($item['ddct_id']);
                $AndroidInfoVO->setImeiOne($imeiList[intval($item['imei_id'])]??'');
                $AndroidInfoVO->setImeiTwo($imeiList[intval($item['imei_id_two'])]??'');
                $AndroidInfoVO->setSn($snList[intval($item['sn_id'])]??'');
                $AndroidInfoVO->setOaid($oaidList[intval($item['oaid_id'])]??'');
                $AndroidInfoVO->setUa($uaList[intval($item['ua_id'])]??'');
                $AndroidInfoVO->setDevNet($devNetList[$ddntIdItem]??$DefDeviceNetCtl->getKeyById($ddntIdItem));
                $AndroidInfoVO->setDevPlatform($devPlatformList[$ddptIdItem]??$DefPlatformCtl->getKeyById($ddptIdItem));
                $AndroidInfoVO->setDevLang($devLangList[$ddltIdItem]??$DefDeviceLangCtl->getKeyById($ddltIdItem));
                $AndroidInfoVO->setDevOs($devOsList[$ddotIdItem]??$DefDeviceOsCtl->getKeyById($ddotIdItem));
                $AndroidInfoVO->setDevModel($devModelList[$ddmtIdItem]??$DefDeviceModelCtl->getKeyById($ddmtIdItem));
                $AndroidInfoVO->setDevBrand($devBrandList[$ddbtIdItem]??$DefDeviceBrandCtl->getKeyById($ddbtIdItem));
                $AndroidInfoVO->setDevCode($devCodeList[$ddctIdItem]??$DefDeviceCodeCtl->getKeyById($ddctIdItem));
                $AndroidInfoVO->setDevWidth(intval($item['dani_width']));
                $AndroidInfoVO->setDevHeight(intval($item['dani_height']));
                $listData[$daniId]  = $AndroidInfoVO;
            }
        }
        return $listData;
    }

    /**
     * @param array $uaIdList
     * @return array
     * 批量获取ua
     */
    public function getUaByIdBatch(array $uaIdList):array
    {
        if(count($uaIdList) < 1) return [];
        $isFail     = false;
        $sql        = 'SELECT ua_id, ua_val FROM '.$this->DbAuto->getTableNameAll('idx_user_agent').' WHERE ua_id IN('.implode(',', $uaIdList).')';
        $list       = $this->DbAuto->getData($sql, $isFail);
        $listData   = [];
        if(!$isFail && CommArray::isForeach($list)) foreach ($list as $item){
            $uaIdItem               = intval($item['ua_id']??0);
            if($uaIdItem < 1) continue;
            $listData[$uaIdItem]    = $item['ua_val'];
        }
        return $listData;
    }

    /**
     * @param array $snIdList
     * @return array
     * 批量获取sn
     */
    public function getSnByIdBatch(array $snIdList):array
    {
        if(count($snIdList) < 1) return [];
        $isFail     = false;
        $sql        = 'SELECT sn_id, sn_val FROM '.$this->DbAuto->getTableNameAll('idx_sn').' WHERE sn_id IN('.implode(',', $snIdList).')';
        $list       = $this->DbAuto->getData($sql, $isFail);
        $listData   = [];
        if(!$isFail && CommArray::isForeach($list)) foreach ($list as $item){
            $snIdItem               = intval($item['sn_id']??0);
            if($snIdItem < 1) continue;
            $listData[$snIdItem]    = $item['sn_val'];
        }
        return $listData;
    }

    /**
     * @param array $imeiIdList
     * @return array
     * 批量获取imei
     */
    public function getImeiByIdBatch(array $imeiIdList):array
    {
        if(count($imeiIdList) < 1) return [];
        $isFail     = false;
        $sql        = 'SELECT imei_id, imei_val FROM '.$this->DbAuto->getTableNameAll('idx_imei').' WHERE imei_id IN('.implode(',', $imeiIdList).')';
        $list       = $this->DbAuto->getData($sql, $isFail);
        $listData   = [];
        if(!$isFail && CommArray::isForeach($list)) foreach ($list as $item){
            $imeiIdItem             = intval($item['imei_id']??0);
            if($imeiIdItem < 1) continue;
            $listData[$imeiIdItem]  = $item['imei_val'];
        }
        return $listData;
    }

    /**
     * @param array $oaidIdList
     * @return array
     * 批量获取oaid
     */
    public function getOaidByIdBatch(array $oaidIdList):array
    {
        if(count($oaidIdList) < 1) return [];
        $isFail     = false;
        $sql        = 'SELECT oaid_id, oaid_val FROM '.$this->DbAuto->getTableNameAll('idx_oaid').' WHERE oaid_id IN('.implode(',', $oaidIdList).')';
        $list       = $this->DbAuto->getData($sql, $isFail);
        $listData   = [];
        if(!$isFail && CommArray::isForeach($list)) foreach ($list as $item){
            $oaidIdItem             = intval($item['oaid_id']??0);
            if($oaidIdItem < 1) continue;
            $listData[$oaidIdItem]  = $item['oaid_val'];
        }
        return $listData;
    }

    /**
     * @param array $visiIdList
     * @return array
     * 批量获取visitor
     */
    public function getVisitorByIdBatch(array $visiIdList):array
    {
        if(count($visiIdList) < 1) return [];
        $isFail     = false;
        $sql        = 'SELECT visi_id, visi_val FROM '.$this->DbAuto->getTableNameAll('idx_visitor').' WHERE visi_id IN('.implode(',', $visiIdList).')';
        $list       = $this->DbAuto->getData($sql, $isFail);
        $listData   = [];
        if(!$isFail && CommArray::isForeach($list)) foreach ($list as $item){
            $visiIdItem             = intval($item['visi_id']??0);
            if($visiIdItem < 1) continue;
            $listData[$visiIdItem]  = $item['visi_val'];
        }
        return $listData;
    }

    /**
     * @param array $idfvIdList
     * @return array
     * 批量获取idfv
     */
    public function getIdfvByIdBatch(array $idfvIdList):array
    {
        if(count($idfvIdList) < 1) return [];
        $isFail     = false;
        $sql        = 'SELECT idfv_id, idfv_val FROM '.$this->DbAuto->getTableNameAll('idx_idfv').' WHERE idfv_id IN('.implode(',', $idfvIdList).')';
        $list       = $this->DbAuto->getData($sql, $isFail);
        $listData   = [];
        if(!$isFail && CommArray::isForeach($list)) foreach ($list as $item){
            $idfvIdItem             = intval($item['idfv_id']??0);
            if($idfvIdItem < 1) continue;
            $listData[$idfvIdItem]  = $item['idfv_val'];
        }
        return $listData;
    }

    /**
     * @param array $idfaIdList
     * @return array
     * 批量获取idfa
     */
    public function getIdfaByIdBatch(array $idfaIdList):array
    {
        if(count($idfaIdList) < 1) return [];
        $isFail     = false;
        $sql        = 'SELECT idfa_id, idfa_val FROM '.$this->DbAuto->getTableNameAll('idx_idfa').' WHERE idfa_id IN('.implode(',', $idfaIdList).')';
        $list       = $this->DbAuto->getData($sql, $isFail);
        $listData   = [];
        if(!$isFail && CommArray::isForeach($list)) foreach ($list as $item){
            $idfaIdItem             = intval($item['idfa_id']??0);
            if($idfaIdItem < 1) continue;
            $listData[$idfaIdItem]  = $item['idfa_val'];
        }
        return $listData;
    }

    /**
     * @param array $dapiIdList
     * @return array
     * getAppleInfoSrcBatch
     */
    public function getAppleInfoSrcBatch(array $dapiIdList):array
    {
        if(count($dapiIdList) < 1) return [];
        $isFail     = false;
        $sql        = 'SELECT dapi_id, idfv_id, idfa_id, ua_id, ddnt_id, ddpt_id, ddlt_id, ddot_id, ddmt_id, dapi_width, dapi_height FROM '.$this->DbAuto->getTableNameAll('device_apple_info').' WHERE dapi_id IN('.implode(',', $dapiIdList).')';
        $list       = $this->DbAuto->getData($sql, $isFail);
        $listData   = [];
        if(!$isFail && CommArray::isForeach($list)){
            foreach ($list as $item){
                $dapiIdItem             = intval($item['dapi_id']??0);
                if($dapiIdItem < 1) continue;
                $listData[$dapiIdItem]  = $item;
            }
        }
        return $listData;
    }

    /**
     * @param array $dapiIdList
     * @return array
     * getAppleInfoBatch
     */
    public function getAppleInfoBatch(array $dapiIdList):array
    {
        $list       = $this->getAppleInfoSrcBatch($dapiIdList);
        $listData   = [];
        if(CommArray::isForeach($list)){
            $DefDeviceNetCtl    = DefDeviceNetCtl::tag();
            $DefPlatformCtl     = DefPlatformCtl::tag();
            $DefDeviceLangCtl   = DefDeviceLangCtl::tag();
            $DefDeviceOsCtl     = DefDeviceOsCtl::tag();
            $DefDeviceModelCtl  = DefDeviceModelCtl::tag();
            // idfv
            $idfvIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'idfv_id'))));
            $idfvList           = $this->getIdfvByIdBatch($idfvIdList);
            // idfa
            $idfaIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'idfa_id'))));
            $idfaList           = $this->getIdfaByIdBatch($idfaIdList);
            // ua
            $uaIdList           = array_unique(array_map('intval', array_filter(array_column($list, 'ua_id'))));
            $uaList             = $this->getUaByIdBatch($uaIdList);
            // devNet
            $ddntIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'ddnt_id'))));
            $devNetList         = $DefDeviceNetCtl->getExtStrByIdBatch($ddntIdList, DefDeviceNetCtl::EXT_NAME);
            // devPlatform
            $ddptIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'ddpt_id'))));
            $devPlatformList    = $DefPlatformCtl->getExtStrByIdBatch($ddptIdList, DefPlatformCtl::EXT_NAME);
            // devLang
            $ddltIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'ddlt_id'))));
            $devLangList        = $DefDeviceLangCtl->getExtStrByIdBatch($ddltIdList, DefDeviceLangCtl::EXT_NAME);
            // devOs
            $ddotIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'ddot_id'))));
            $devOsList          = $DefDeviceOsCtl->getExtStrByIdBatch($ddotIdList, DefDeviceOsCtl::EXT_NAME);
            // devModel
            $ddmtIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'ddmt_id'))));
            $devModelList       = $DefDeviceModelCtl->getExtStrByIdBatch($ddmtIdList, DefDeviceModelCtl::EXT_NAME);
            foreach ($list as $dapiId => $item){
                $AppleInfoVO        = new AppleInfoVO();
                $ddntIdItem         = intval($item['ddnt_id']);
                $ddptIdItem         = intval($item['ddpt_id']);
                $ddltIdItem         = intval($item['ddlt_id']);
                $ddotIdItem         = intval($item['ddot_id']);
                $ddmtIdItem         = intval($item['ddmt_id']);
                $AppleInfoVO->setIdfv($idfvList[intval($item['idfv_id'])]??'');
                $AppleInfoVO->setIdfa($idfaList[intval($item['idfa_id'])]??'');
                $AppleInfoVO->setUa($uaList[intval($item['ua_id'])]??'');
                $AppleInfoVO->setDevNet($devNetList[$ddntIdItem]??$DefDeviceNetCtl->getKeyById($ddntIdItem));
                $AppleInfoVO->setDevPlatform($devPlatformList[$ddptIdItem]??$DefPlatformCtl->getKeyById($ddptIdItem));
                $AppleInfoVO->setDevLang($devLangList[$ddltIdItem]??$DefDeviceLangCtl->getKeyById($ddltIdItem));
                $AppleInfoVO->setDevOs($devOsList[$ddotIdItem]??$DefDeviceOsCtl->getKeyById($ddotIdItem));
                $AppleInfoVO->setDevModel($devModelList[$ddmtIdItem]??$DefDeviceModelCtl->getKeyById($ddmtIdItem));
                $AppleInfoVO->setDevWidth(intval($item['dapi_width']));
                $AppleInfoVO->setDevHeight(intval($item['dapi_height']));
                $listData[$dapiId]  = $AppleInfoVO;
            }
        }
        return $listData;
    }

    /**
     * @param array $dopiIdList
     * @return array
     * getOtherInfoSrcBatch
     */
    public function getOtherInfoSrcBatch(array $dopiIdList):array
    {
        if(count($dopiIdList) < 1) return [];
        $isFail     = false;
        $sql        = 'SELECT dopi_id, visi_id, ua_id, ddnt_id, ddpt_id, ddlt_id, ddot_id, ddmt_id, dopi_width, dopi_height FROM '.$this->DbAuto->getTableNameAll('device_other_info').' WHERE dopi_id IN('.implode(',', $dopiIdList).')';
        $list       = $this->DbAuto->getData($sql, $isFail);
        $listData   = [];
        if(!$isFail && CommArray::isForeach($list)){
            foreach ($list as $item){
                $dopiIdItem             = intval($item['dopi_id']??0);
                if($dopiIdItem < 1) continue;
                $listData[$dopiIdItem]  = $item;
            }
        }
        return $listData;
    }

    /**
     * @param array $dopiIdList
     * @return array
     * getOtherInfoBatch
     */
    public function getOtherInfoBatch(array $dopiIdList):array
    {
        $list       = $this->getOtherInfoSrcBatch($dopiIdList);
        $listData   = [];
        if(CommArray::isForeach($list)){
            $DefDeviceNetCtl    = DefDeviceNetCtl::tag();
            $DefPlatformCtl     = DefPlatformCtl::tag();
            $DefDeviceLangCtl   = DefDeviceLangCtl::tag();
            $DefDeviceOsCtl     = DefDeviceOsCtl::tag();
            $DefDeviceModelCtl  = DefDeviceModelCtl::tag();
            // visi_id
            $visiIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'visi_id'))));
            $visitorList        = $this->getVisitorByIdBatch($visiIdList);
            // ua
            $uaIdList           = array_unique(array_map('intval', array_filter(array_column($list, 'ua_id'))));
            $uaList             = $this->getUaByIdBatch($uaIdList);
            // devNet
            $ddntIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'ddnt_id'))));
            $devNetList         = $DefDeviceNetCtl->getExtStrByIdBatch($ddntIdList, DefDeviceNetCtl::EXT_NAME);
            // devPlatform
            $ddptIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'ddpt_id'))));
            $devPlatformList    = $DefPlatformCtl->getExtStrByIdBatch($ddptIdList, DefPlatformCtl::EXT_NAME);
            // devLang
            $ddltIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'ddlt_id'))));
            $devLangList        = $DefDeviceLangCtl->getExtStrByIdBatch($ddltIdList, DefDeviceLangCtl::EXT_NAME);
            // devOs
            $ddotIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'ddot_id'))));
            $devOsList          = $DefDeviceOsCtl->getExtStrByIdBatch($ddotIdList, DefDeviceOsCtl::EXT_NAME);
            // devModel
            $ddmtIdList         = array_unique(array_map('intval', array_filter(array_column($list, 'ddmt_id'))));
            $devModelList       = $DefDeviceModelCtl->getExtStrByIdBatch($ddmtIdList, DefDeviceModelCtl::EXT_NAME);
            foreach ($list as $dopiId => $item){
                $OtherInfoVO        = new OtherInfoVO();
                $ddntIdItem         = intval($item['ddnt_id']);
                $ddptIdItem         = intval($item['ddpt_id']);
                $ddltIdItem         = intval($item['ddlt_id']);
                $ddotIdItem         = intval($item['ddot_id']);
                $ddmtIdItem         = intval($item['ddmt_id']);
                $OtherInfoVO->setUa($uaList[intval($item['ua_id'])]??'');
                $OtherInfoVO->setDevNet($devNetList[$ddntIdItem]??$DefDeviceNetCtl->getKeyById($ddntIdItem));
                $OtherInfoVO->setDevPlatform($devPlatformList[$ddptIdItem]??$DefPlatformCtl->getKeyById($ddptIdItem));
                $OtherInfoVO->setDevLang($devLangList[$ddltIdItem]??$DefDeviceLangCtl->getKeyById($ddltIdItem));
                $OtherInfoVO->setDevOs($devOsList[$ddotIdItem]??$DefDeviceOsCtl->getKeyById($ddotIdItem));
                $OtherInfoVO->setDevModel($devModelList[$ddmtIdItem]??$DefDeviceModelCtl->getKeyById($ddmtIdItem));
                $OtherInfoVO->setDevWidth(intval($item['dopi_width']));
                $OtherInfoVO->setDevHeight(intval($item['dopi_height']));
                $OtherInfoVO->setVisitor($visitorList[intval($item['visi_id'])]??'');
                $listData[$dopiId]  = $OtherInfoVO;
            }
        }
        return $listData;
    }
}